﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AMS.SubCipherSolver
{
    class KeyValuePairComparer<T,K> : IComparer<KeyValuePair<T,K>> where K : IComparable
    {
        public bool LowToHigh { get; set; }

        public KeyValuePairComparer(bool lowToHigh)
        {
            this.LowToHigh = lowToHigh;
        }

        public int Compare(KeyValuePair<T, K> x, KeyValuePair<T, K> y)
        {
            if (LowToHigh)
                return x.Value.CompareTo(y.Value);
            else
                return y.Value.CompareTo(x.Value);
        }
    }
}
